package com.aeye.mbr.common.result;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by chengshengru on 17-9-2.
 */
public class BootstrapTableParams implements Serializable{

    private String search = "";


    private Integer offset = 0;


    private Integer limit = 10;


    private String order;


    private String sort;


    private Map<String,Object> attribute = new HashMap<>();

    public int getPage(){
        if(offset!=null && limit!=null){
            if(limit != 0){
                return offset.intValue()/limit.intValue()+1;
            }
        }
        return  1;
    }


    public String getSearch() {
        return search;
    }

    public void setSearch(String search) {
       this.search = search;
    }

    public Integer getOffset() {
        return offset;
    }

    public void setOffset(Integer offset) {
        this.offset = offset;
    }

    public Integer getLimit() {
        return limit;
    }

    public void setLimit(Integer limit) {
        this.limit = limit;
    }

    public String getOrder() {
        return order;
    }

    public void setOrder(String order) {
        this.order = order;
    }


    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public void addAttribute(String key,Object value){
        attribute.put(key, value);
    }


    public boolean containsKey(String key){
        return attribute.containsKey(key);
    }


    public <T extends Object>T getAttribute(String key){
        return (T)attribute.get(key);
    }


    public Map<String, Object> getAllAttributes() {
        return attribute;
    }
}
